package com.a2020111222.test;

import com.a2020111222.test.mapper.classMapper;
import com.a2020111222.test.mapper.menuMapper;
import com.a2020111222.test.pojo.classInfo;
import com.a2020111222.test.pojo.menu;
import com.a2020111222.test.tool.MyBatisUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.Reader;
import java.util.List;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2022/9/5 11:05
 */
public class test {
        private SqlSession sqlSession= MyBatisUtils.getSession();
        menuMapper menuMapper= sqlSession.getMapper(menuMapper.class);
        @Test
        public void findAllMenuTest(){
//              注解查询
                menu menu=menuMapper.findById(1);
                menu.setStuName("王小三");
//              注解修改
                menuMapper.updateById(menu);
                System.out.println(menu);
        }
        /**
         * @description:  注解参数
         * @param: []
         * @return: void
         * @author Yang
         * @date: 2022/10/30 11:44
         */
        @Test
        public void findPageListByIdTest() {
                List<menu> ListMenu=menuMapper.findPageListById(30,20);
                System.out.println(ListMenu);
        }


        /**
         * @description:  注解一对多
         * @param: []
         * @return: void
         * @author Yang
         * @date: 2022/10/30 11:40
         */
        @Test
        public void selectListTest() {
                classMapper classmapper= sqlSession.getMapper(classMapper.class);
                List<classInfo> classInfo= classmapper.selectList2(1623088281968L);
                System.out.println(classInfo);
        }

        @After
        public void destroy(){
                sqlSession.commit();
                sqlSession.close();
        }

}
